package gov.pbc.nn.kjgl.gzjh.dao;

import gov.pbc.nn.core.bdf.IUserSelect;
import gov.pbc.nn.core.bdf.service.UserService.DefaultUserRowMapper;
import gov.pbc.nn.core.dao.PbcnnCoreJdbcDao;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Component;
import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.context.ContextHolder;
import com.bstek.dorado.data.provider.Criteria;
import com.bstek.dorado.data.provider.Page;

/**
 * 人员下拉列表，选择该部门下的所有人
 * @author jack.zhao
 *
 */
@Component("gzSlectUserDao")
public class GzSlectUserDao implements IUserSelect {
	@Override
	public void loadUsers(Page<IUser> page, Criteria criteria, Map<String, Object> params)  {
		PbcnnCoreJdbcDao jdbc = ContextHolder.getBean(PbcnnCoreJdbcDao.BEAN_ID);
		
		String  sql="select T.*  from  (SELECT U.*, D.ID_ as DEPT_ID_ , D.NAME_ as DEPT_NAME_  FROM T_USER U INNER JOIN bdf2_user_dept ud ON U.USERNAME_ = ud.USERNAME_  INNER JOIN t_dept D ON D.ID_=ud.DEPT_ID_  ) T  where T.DEPT_ID_ =:deptId ";
		Map<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("deptId", ContextHolder.getLoginUser().getDepts().get(0).getId());
		jdbc.pagingQuery(page,sql,new DefaultUserRowMapper(),parameter);
	}

}
